#ifndef GEOCOORDINATE_H
#define GEOCOORDINATE_H

#include <QObject>
#include <QGeoCoordinate>

QTM_USE_NAMESPACE

class GeoCoordinate: public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
    Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY positionChanged)
    Q_PROPERTY(double latitude  READ latitude  WRITE setLatitude  NOTIFY positionChanged)
    Q_PROPERTY(double distance  READ distance  WRITE setDistance  NOTIFY distanceChanged)
    Q_PROPERTY(double bearing   READ bearing   WRITE setBearing   NOTIFY distanceChanged)

private:
    QString _name;
    QGeoCoordinate q_coord;
    double _distance, ;
    double _bearing;

signals:
    void positionChanged();
    void distanceChanged();
    void nameChanged();

public:
    QString name() const
    { return _name; }

    double longitude() const
    { return q_coord.longitude(); }

    double latitude()  const
    { return q_coord.latitude();  }

    double distance()  const
    { return _distance;  }

    double bearing()  const
    { return _bearing;  }

    void   setName(QString value)
    { _name = value; emit positionChanged(); }

    void   setLongitude(double value)
    { q_coord.setLongitude(value); emit positionChanged(); }

    void   setLatitude(double value)
    { q_coord.setLatitude(value);  emit positionChanged(); }

    void   setDistance(double value)
    { _distance = value;  emit distanceChanged(); }

    void   setBearing(double value)
    { _bearing = value;  emit distanceChanged(); }

    GeoCoordinate(QObject * parent = 0) : QObject(parent)
    { setLatitude(0); setLongitude(0); setDistance(0); setBearing(0); }

    GeoCoordinate(const GeoCoordinate& pos) : QObject()
    { setLatitude(pos.latitude()); setLongitude(pos.longitude()); }

    GeoCoordinate operator=(const GeoCoordinate& pos)
    { return GeoCoordinate(pos); }

public Q_SLOTS:
    void referenceChanged(double r_lat, double r_long);
    void referenceChanged(const QGeoCoordinate& r_coord);
};


#endif // GEOCOORDINATE_H
